//
//  ViewController.m
//  WaterfallFlow
//
//  Created by 方正刚 on 2017/8/21.
//  Copyright © 2017年 方正刚. All rights reserved.
//

#import "ViewController.h"
#import "WaterFallFlowModel.h"
#import "WaterFallFlowLayout.h"
#import "FallFlowCell.h"

@interface ViewController ()

//瀑布流数据
@property (nonatomic, strong) NSArray *dataList;

@property (weak, nonatomic) IBOutlet WaterFallFlowLayout *flowLayout;

@end

@implementation ViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.flowLayout.dataList = self.dataList.mutableCopy;
    
    self.flowLayout.columns = 3;

}

/**
 加载数据

 @return 返回数据
 */
- (NSArray *)dataList {
    if (_dataList == nil) {
        _dataList = [WaterFallFlowModel datas];
    }
    return  _dataList;
}


#pragma mark - UIColectionVeiwDataSource -
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return self.dataList.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    WaterFallFlowModel *model = self.dataList[indexPath.row];
    
    FallFlowCell  *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FlowCellID" forIndexPath:indexPath];
    
    cell.model = model;
    
    return cell;
}

@end
